<template>
  <div class="newslist">
    <van-card
      v-for="(item,index) in $store.state.news.jishilist"
      :key="index"
      :desc="item.brief"
      :title="item.title"
      :thumb="item.image"
      @click="postname(item.title)"
    >
      <template #num>
        <div>
          {{item.focus_date}}
        </div>
      </template>
      <template #price>
        <div>
          {{item.keywords}}
        </div>
      </template>
    </van-card>
  </div>
</template>
<script>
import { getNewsList } from '@/api/news.js'
import { mapState } from 'vuex'
export default {

  data() {
    return {
      newslist: []
    }
  },
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList() {
      const res = await getNewsList()
      this.newslist = res.data.data
      this.$store.commit('news/getNews', this.newslist)
    },
    postname(title) {
      this.$router.push('/home/newsinfo/' + title)
      this.$store.commit('news/filternews', title)
    }
  },
  computed: {
    ...mapState(['news/jishilist'])
  }
}
</script>
<style lang="scss" scoped>
.newslist {
}
</style>